package com.traffic.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.traffic.domain.PerReturninfor;
import com.traffic.service.IPerReturninforService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 回访主要信息Controller
 * 
 * @author 郭世纪
 * @date 2024-12-08
 */
@RestController
@RequestMapping("/returninfor")
public class PerReturninforController extends BaseController
{
    @Autowired
    private IPerReturninforService perReturninforService;

    /**
     * 查询回访主要信息列表
     */
    @RequiresPermissions("document:returninfor:list")
    @GetMapping("/list")
    public TableDataInfo list(PerReturninfor perReturninfor)
    {
        startPage();
        List<PerReturninfor> list = perReturninforService.selectPerReturninforList(perReturninfor);
        return getDataTable(list);
    }

    /**
     * 导出回访主要信息列表
     */
    @RequiresPermissions("document:returninfor:export")
    @Log(title = "回访主要信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PerReturninfor perReturninfor)
    {
        List<PerReturninfor> list = perReturninforService.selectPerReturninforList(perReturninfor);
        ExcelUtil<PerReturninfor> util = new ExcelUtil<PerReturninfor>(PerReturninfor.class);
        util.exportExcel(response, list, "回访主要信息数据");
    }

    /**
     * 获取回访主要信息详细信息
     */
    @RequiresPermissions("document:returninfor:query")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(perReturninforService.selectPerReturninforByID(ID));
    }

    /**
     * 新增回访主要信息
     */
    @RequiresPermissions("document:returninfor:add")
    @Log(title = "回访主要信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PerReturninfor perReturninfor)
    {
        return toAjax(perReturninforService.insertPerReturninfor(perReturninfor));
    }

    /**
     * 修改回访主要信息
     */
    @RequiresPermissions("document:returninfor:edit")
    @Log(title = "回访主要信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PerReturninfor perReturninfor)
    {
        return toAjax(perReturninforService.updatePerReturninfor(perReturninfor));
    }

    /**
     * 删除回访主要信息
     */
    @RequiresPermissions("document:returninfor:remove")
    @Log(title = "回访主要信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(perReturninforService.deletePerReturninforByIDs(IDs));
    }
}
